#pragma once
namespace cp
{
	template<class _iterator, class Ref, class Str>
	struct _reverse_iterator
	{
		typedef _reverse_iterator<_iterator, Ref, Str> Self;

		_iterator _it;
		_reverse_iterator(_iterator it)
			:_it(it)
		{}

		Ref operator*()
		{
			_iterator tmp = _it;
			return *(--tmp);
		}

		Str operator->()
		{
			//return _it.operator->();
			return &(operator*());
		}

		Self& operator++()
		{
			--_it;
			return *this;
		}

		Self operator++(int)
		{
			Self tmp = _it;
			--_it;
			return tmp;
		}

		Self& operator--()
		{
			++_it;
			return *this;
		}

		Self operator--(int)
		{
			Self tmp = _it;
			++_it;
			return tmp;
		}

		bool operator!=(const Self& s)
		{
			return _it != s._it;
		}

		bool operator==(const Self& s)
		{
			return _it == s._it;
		}
	};
}
